package com.ruoyi.map.controller;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.map.domain.FhMapFishtype;
import com.ruoyi.map.domain.FhMapGuide;
import com.ruoyi.map.service.IFhMapGuideService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
* 垂钓指南
* */
@RestController
@RequestMapping("/map/guide")
public class FhMapGuideController extends BaseController {

    @Autowired
    private IFhMapGuideService fhMapGuideService;

    /**
     * 查询鱼类管理列表
     */
    @GetMapping("/list/{fishId}")
    @PreAuthorize("@ss.hasPermi('map:fishtype:add')")
    public R<List<FhMapGuide>> list(@PathVariable("fishId") Long fishId) {
        List<FhMapGuide> fhMapGuides = fhMapGuideService.guideList(fishId);
        return R.ok(fhMapGuides);
    }


    /**
     * 新增垂钓指南
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FhMapGuide fhMapGuide)
    {
        return toAjax(fhMapGuideService.insertGuide(fhMapGuide));
    }


    /**
     * 更新垂钓指南
     */
    @PostMapping("/updata")
    public AjaxResult updata(@RequestBody FhMapGuide fhMapGuide)
    {
        return toAjax(fhMapGuideService.updataGuide(fhMapGuide));
    }


    /**
     * 删除垂钓指南
     */
    @Log(title = "鱼类管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhMapGuideService.deleteGuide(ids));
    }

}
